<template>
	<view id="my_nav">
		<!-- 导航栏 -->
		<view class="nav">
			<view :style="{'height':statusBarHeight+'px'}"></view>
			<view class="nav_box">
				<view class="address" @click="openAddres">
					<text>{{city}}</text>
					<icon class="icon_dowm"></icon>
				</view>
				<view class="nav_title">{{title}}</view>
			</view>
		</view>
		<!-- 空白部分 -->
		<view :style="{'height':`${statusBarHeight*2+88}rpx`}"></view>
		<!-- 省市区选择 -->
		<simple-address ref="simpleAddress" :pickerValueDefault="[0,0,0]" @onConfirm="onConfirm" themeColor="#007AFF" @onCancel="onCancel" :area="false"></simple-address>
	</view>
</template>

<script>
	const app = getApp();
	import simpleAddress from '@/components/simple-address/simple-address.vue';  //省市区选择
	export default {
		props:{
			title:{
				type:String,
				default:'小咪'
			},
			city:{
				type:String,
				default:'全国'
			}
		},
		components: {
			simpleAddress
		},
		data() {
			return {
				statusBarHeight: app.globalData.statusBarHeight,
			}
		},
		methods: {
			// 省市区选择
			openAddres(){
				this.$refs.simpleAddress.open();
			},
			
			// 确定按钮
			onConfirm(e) {
				this.$emit('selectCity',e.labelArr[1])
			},
			
			onCancel(){}
		}
	}
</script>

<style lang="scss">
	.nav {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		width: 100%;
		background: #FFFFFF;

		.nav_box {
			height: 88rpx;
			padding: 0 32rpx;
			position: relative;

			.address {
				position: absolute;
				top: 50%;
				transform: translateY(-50%);
				left: 32rpx;
				font-size: 24rpx;
				display: flex;
				align-items: center;

				.icon_dowm {
					width: 14rpx;
					height: 8rpx;
					background: url(../../static/image/icon-lysm-xx.png) no-repeat;
					background-size: 100% 100%;
					margin-left: 10rpx;
				}
			}

			.nav_title {
				line-height: 88rpx;
				text-align: center;
				font-size: 30rpx;
			}
		}
	}
</style>
